package com.yanqu.road.server.gameplayer.module.activity.tomb.service;

import com.google.protobuf.InvalidProtocolBufferException;
import com.yanqu.road.pb.syncMessage.SyncMessage;
import com.yanqu.road.pb.tomb.Tomb;
import com.yanqu.road.server.game.service.IGameServiceCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.sync.message.SyncResponse;

public class TombEliteNpcInfoPushServiceCmd implements IGameServiceCommand {

    @Override
    public SyncResponse execute(SyncMessage.Request request) throws InvalidProtocolBufferException {
        SyncResponse syncResponse = new SyncResponse();
        Tomb.TombEliteNpcInfoPushCrossToGameReq resp = Tomb.TombEliteNpcInfoPushCrossToGameReq.parseFrom(request.getDataBytes());
        Tomb.TombEliteNpcInfoPush.Builder messageBuilder = resp.getResp().toBuilder();
        for (Long aLong : resp.getUserIdListList()) {
            GamePlayer onlinePlayer = GamePlayerMgr.getOnlinePlayer(aLong);
            if (onlinePlayer == null) {
                continue;
            }
            onlinePlayer.sendPacket(ClientProtocol.U_TOMB_ELITE_NPC_INFO_PUSH, messageBuilder);
        }

        return syncResponse;
    }
}
